package com.eeds.controller.pc;

import com.eeds.base.BaseController;
import com.eeds.common.model.BaseWrapper;
import com.eeds.interceptor.NeedAuth;
import com.eeds.model.work.req.ReqAddWorkAttendanceVO;
import com.eeds.model.work.req.ReqGetWorkAttendanceInfoVO;
import com.eeds.model.work.req.ReqUpdateWorkAttendanceVO;
import com.eeds.model.work.res.ResGetWorkAttendanceInfoVO;
import com.eeds.service.work.WorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@Api(value = "工作接口", description = "工作接口")
@RequestMapping("pc/work/")
public class WorkController extends BaseController {

    @Autowired
    private WorkService workService;


    /**
     * description:添加考勤记录
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: reqAddProjectVO
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/addWorkAttendance", method = RequestMethod.POST)
    @ApiOperation("添加考勤记录")
    public BaseWrapper<Integer> addWorkAttendance(@Valid @ModelAttribute ReqAddWorkAttendanceVO reqAddWorkAttendanceVO){
        Integer result = workService.addWorkAttendance(reqAddWorkAttendanceVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:修改考勤记录
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: reqAddProjectVO
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/updateWorkAttendance", method = RequestMethod.POST)
    @ApiOperation("修改考勤记录")
    public BaseWrapper<Integer> updateWorkAttendance(@Valid @ModelAttribute ReqUpdateWorkAttendanceVO reqUpdateWorkAttendanceVO){
        Integer result = workService.updateWorkAttendance(reqUpdateWorkAttendanceVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:获取考勤记录信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: reqAddProjectVO
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/getWorkAttendanceInfo", method = RequestMethod.GET)
    @ApiOperation("获取考勤记录信息")
    public BaseWrapper<ResGetWorkAttendanceInfoVO> getWorkAttendanceInfo(@Valid @ModelAttribute ReqGetWorkAttendanceInfoVO reqGetWorkAttendanceInfoVO){
        ResGetWorkAttendanceInfoVO result = workService.getWorkAttendanceInfo(reqGetWorkAttendanceInfoVO);
        return new BaseWrapper<>(result);
    }

}
